package com.jxccp.ui.entities;

import com.jxccp.im.util.log.JXLog;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 追一机器人商品订单实体
 */
public class ZhuiyiProductOrderEntity implements Serializable {

    /**
     * 订单待发货
     */
    public static final String ORDER_STATUS_WAIT_SELLER_SEND_GOODS = "WAIT_SELLER_SEND_GOODS";

    /**
     * 待付款
     */
    public static final String ORDER_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";

    /**
     * 待收货
     */
    public static final String ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS = "WAIT_BUYER_CONFIRM_GOODS";

    /**
     * 交易关闭
     */
    public static final String ORDER_STATUS_TRADE_CLOSED = "TRADE_CLOSED";

    /**
     * 交易成功
     */
    public static final String ORDER_STATUS_TRADE_BUYER_SIGNED = "TRADE_BUYER_SIGNED";


    /**
     * 虚拟
     */
    public static final int ORDER_TRADE_TYPE_VIRTUAL = 1;
    /**
     * 海淘
     */
    public static final int ORDER_TRADE_TYPE_HAITAO = 2;
    /**
     * 商家
     */
    public static final int ORDER_TRADE_TYPE_MERCHANT = 3;
    /**
     * 自营
     */
    public static final int ORDER_TRADE_TYPE_SELF_OPERATED = 4;
    /**
     * 京东
     */
    public static final int ORDER_TRADE_TYPE_JD = 5;

    /**
     * 商铺id
     */
    private String shopId;
    /**
     * 商铺名称
     */
    private String shopName;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 订单时间
     */
    private String orderTime;

    /**
     * 订单状态
     */
    private String orderStatus;

    /**
     * 交易类型
     */
    private int orderTradeType;


    /**
     * 支付时间
     */
    private String orderPayTime;

    /**
     * 签收时间
     */
    private String orderSignTime;

    /**
     * 商品列表
     */
    private List<ZhuiyiProductEntity> productList;

    /**
     * 订单实付总金额
     */
    private String orderTotalPay;

    /**
     * 订单商品总数量
     */
    private int productTotalNum;

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getOrderPayTime() {
        return orderPayTime;
    }

    public void setOrderPayTime(String orderPayTime) {
        this.orderPayTime = orderPayTime;
    }

    public String getOrderSignTime() {
        return orderSignTime;
    }

    public void setOrderSignTime(String orderSignTime) {
        this.orderSignTime = orderSignTime;
    }

    public int getOrderTradeType() {
        return orderTradeType;
    }

    public void setOrderTradeType(int orderTradeType) {
        this.orderTradeType = orderTradeType;
    }

    public String getOrderTotalPay() {
        return orderTotalPay;
    }

    public void setOrderTotalPay(String orderTotalPay) {
        this.orderTotalPay = orderTotalPay;
    }

    public List<ZhuiyiProductEntity> getProductList() {
        if (productList == null) {
            return new ArrayList<>();
        }
        return productList;
    }

    public void setProductList(List<ZhuiyiProductEntity> productList) {
        this.productList = productList;
//        if (productList != null) {
//            try {
//                double totalPay = 0;
//                for (ZhuiyiProductEntity zhuiyiProductEntity : productList) {
//                    totalPay = totalPay + Double.parseDouble(zhuiyiProductEntity
//                            .getProductActualPayment());
//                }
//                DecimalFormat df = new DecimalFormat("0.00");
//                setOrderTotalPay(String.valueOf(df.format(totalPay)));
//            } catch (Exception e) {
//                JXLog.e("[ZhuiyiProductOrderEntity.setProductList] set total price exception", e);
//            }
//        }
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ZhuiyiProductOrderEntity{");
        sb.append("shopId=").append(shopId);
        sb.append(", shopName=").append(shopName);
        sb.append(", orderId=").append(orderId);
        sb.append(", orderTime=").append(orderTime);
        sb.append(", orderStatus=").append(orderStatus);
        sb.append(", orderTradeType=").append(orderTradeType);
        sb.append(", orderPayTime=").append(orderPayTime);
        sb.append(", orderSignTime=").append(orderSignTime);
        sb.append(", productList=").append(productList);
        sb.append(", orderTotalPay=").append(orderTotalPay);
        sb.append(", productTotalNum=").append(productTotalNum);
        sb.append('}');
        return sb.toString();
    }

    public int getProductTotalNum() {
        return productTotalNum;
    }

    public void setProductTotalNum(int productTotalNum) {
        this.productTotalNum = productTotalNum;
    }

}
